Skip to content

fix: atomic dataset unlink via RPC, resolve dedup callbacks, guard metadata fetch errors, harden null count check - #79

Merged
calebyhan merged 10 commits into
mainfrom
fix/duplicate-datasets
May 6, 2026
Merged

fix: atomic dataset unlink via RPC, resolve dedup callbacks, guard metadata fetch errors, harden null count check#79
calebyhan merged 10 commits into
mainfrom
fix/duplicate-datasets

Conversation

@calebyhan

Copy link
Copy Markdown
Owner

Description

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔨 Refactoring (no functional changes)
  • ✅ Test additions or updates
  • 🔧 Configuration/build changes

Related Issues

Closes #75

Changes Made

  • Datasets in one canvas can be reuploaded to another

Checklist

  • My code follows the project's style guidelines (PEP 8 for Python, ESLint for TypeScript)
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Context


…tadata fetch errors, harden null count check
Copilot AI review requested due to automatic review settings April 13, 2026 17:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses dataset deduplication and lifecycle handling in canvas contexts so the same dataset can be reused across canvases, and introduces an RPC to unlink datasets atomically (with optional cleanup) while hardening a few client-side error paths.

Changes:

  • Removed dataset creation-time filename deduplication and moved dedup/reuse logic into useDatasetManager (including cross-canvas reuse by linking an existing completed dataset).
  • Added an atomic “unlink + conditional delete” flow via a new Postgres RPC and switched canvas dataset removal to use it.
  • Improved robustness: resolve progress/status callbacks on dedup early-returns, log realtime subscription failures, and guard metadata fetch errors before metadata merge updates.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
frontend/lib/services/datasetService.ts Removes create-time dedup; adds canvas link/unlink helpers and RPC-based remove-from-canvas.
frontend/hooks/useDatasetManager.ts Implements canvas/global dedup and reuse, updates deletion behavior on canvases, and adds realtime subscription error logging.
backend/database/schema.sql Enables Realtime for canvas_datasets and adds unlink_dataset_from_canvas RPC for atomic unlink + conditional delete.

Comment thread frontend/hooks/useDatasetManager.ts Outdated
Comment thread backend/database/schema.sql
Comment thread backend/database/schema.sql

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread frontend/hooks/useDatasetManager.ts Outdated
Comment thread backend/database/schema.sql Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread frontend/hooks/useDatasetManager.ts Outdated
Comment thread frontend/lib/services/datasetService.ts
Comment thread frontend/lib/services/datasetService.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

frontend/hooks/useDatasetManager.ts:237

  • The lines starting the actual upload lifecycle (onStatusChange?.('pending'), onProgress?.(10), and the createDataset call) are mis-indented relative to the surrounding try { ... } block, which makes the control flow harder to read and easy to misinterpret during maintenance. Run the formatter / fix indentation to match the rest of the file.
        // Step 1: Create dataset with pending status
      onStatusChange?.('pending');
      onProgress?.(10);

      const dbDataset = await DatasetService.createDataset({
        userId,
        filename: file.name,
        fileSize: file.size,
        fileType: file.type || 'text/csv',
      });

Comment thread frontend/lib/services/datasetService.ts
Comment thread frontend/lib/services/datasetService.ts Outdated
Comment thread frontend/lib/services/datasetService.ts Outdated
Comment thread backend/database/schema.sql Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread frontend/hooks/useDatasetManager.ts Outdated
Comment thread backend/database/schema.sql

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread frontend/hooks/useDatasetManager.ts
Comment thread frontend/lib/services/datasetService.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread frontend/hooks/useDatasetManager.ts Outdated
Comment thread frontend/lib/services/datasetService.ts Outdated
@calebyhan
calebyhan requested a review from Copilot May 6, 2026 20:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread frontend/lib/services/datasetService.ts
Comment thread frontend/hooks/useDatasetManager.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

Comment thread frontend/lib/services/datasetService.ts
Comment thread frontend/lib/services/datasetService.ts
Comment thread frontend/hooks/useDatasetManager.ts Outdated
Comment thread frontend/lib/services/datasetService.ts Outdated
@calebyhan
calebyhan requested a review from Copilot May 6, 2026 20:38
@calebyhan
calebyhan merged commit 0b0aa5a into main May 6, 2026
9 of 10 checks passed
@calebyhan
calebyhan deleted the fix/duplicate-datasets branch May 6, 2026 20:52
@calebyhan
calebyhan removed the request for review from Copilot May 6, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix: duplicate datasets in one canvas cannot be re-imported in another canvas

2 participants